var app = sm("do_App");
var page = sm("do_Page");
var nf = sm("do_Notification");
var openHelper = require("helper/open");
var shopId;
var do_ALayout_ws = ui("do_ALayout_ws");
var do_ALayout_wc = ui("do_ALayout_wc");
var do_ALayout_er = ui("do_ALayout_er");
var do_Label_numWs = ui("do_Label_numWs");
var do_Label_numWc = ui("do_Label_numWc");
var do_Label_numEr = ui("do_Label_numEr");
ui("$").setMapping({
	"label_shopName.tag":"id",
	"label_shopName.text":"name",	
	"imageView_logo.source":"fullLogo",
	"labelTotalIncome.tag" : "totalIncome",
	"do_Label_numWs.text" : "waitSendCount",
	"do_Label_numWc.text" : "waitReceiptCount",
	"do_Label_numEr.text" : "waitRefundCount",
	"todayCompletedCount.text" : "todayCompletedCount",
	"totalTodayCompleted.text" : "totalTodayCompleted"
});

ui("$").on("dataRefreshed", function(data, e) {
	shopId = ui("label_shopName").tag;
	var totalIncome = ui("labelTotalIncome").tag;
	ui("labelTotalIncome").text = "收益总计：￥"+totalIncome
	if(do_Label_numWs.text > 0){
		do_ALayout_ws.visible = true;
	}else{
		do_ALayout_ws.visible = false;
	}
	if(do_Label_numWc.text > 0){
		do_ALayout_wc.visible = true;
	}else{
		do_ALayout_wc.visible = false;
	}
	if(do_Label_numEr.text > 0){
		do_ALayout_er.visible = true;
	}else{
		do_ALayout_er.visible = false;
	}
})

ui("do_ALayout_shop").on("touch",'' ,300,function(data, e) {
	openHelper.open("source://view/qshop/manage/shop/detail.ui");
});
ui("do_ALayout_offsell").on("touch",'' ,300,function(data, e) {
	if(shopId){
		openHelper.open("source://view/qshop/manage/product/myOffShelfProduct.ui",{shopId: shopId});
	}
});

ui("do_ALayout_selled").on("touch",'' ,300,function(data, e){
	openHelper.open("source://view/order/supplier/list.ui");
});

//待发货
ui("do_ALayout_waitSend").on("touch",'' ,300,function(data, e){
	openHelper.open("source://view/order/supplier/list.ui", {toPage:"waitSend", shopId:shopId});
});
//待确认
ui("do_ALayout_waitComplate").on("touch",'' ,300,function(data, e){
	openHelper.open("source://view/order/supplier/list.ui", {toPage:"waitComplate", shopId:shopId});
});
//已完成
ui("do_ALayout_hasComplate").on("touch",'' ,300,function(data, e){
	openHelper.open("source://view/order/supplier/list.ui", {toPage:"hasComplate", shopId:shopId});
});

//异常订单
ui("do_ALayout_error").on("touch",'' ,300,function(data, e){
	openHelper.open("source://view/order/supplier/list.ui", {toPage:"error", shopId:shopId});
});
